﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            int answear;
            do
            { 
                Console.WriteLine("Please select task:");
                Console.WriteLine("1-count of positive, negative and zeros from input");
                Console.WriteLine("2-display two-digit numbers divided by 5");
                Console.WriteLine("3-counts amount of digits from input");
                Console.WriteLine("4-displays (10..20) in second power");
                Console.WriteLine("5-displays maximum of input");
                Console.WriteLine("6-displays number of amoebas after defined time");
                Console.WriteLine("7-displays interest you get after defined period");
                Console.WriteLine("8-displays numbers (20..50) which can be divided by 3 but not by 5");
                Console.WriteLine("9-displays reverted input number");
                int choice = Int32.Parse(Console.ReadLine());
            switch (choice)
            {
                case (1):
                    {
                        Console.Clear();
                        CountOfPosNegZer();
                    }
                    break;
                case (2):
                    {
                        Console.Clear();
                        DividedByFive();
                    }
                    break;
                case (3):
                    {
                        Console.Clear();
                        MultiDigitNumber();
                    }
                    break;
                case (4):
                    {
                        Console.Clear();
                        SecondPower();
                    }
                    break;
                case (5):
                    {
                        Console.Clear();
                        MaxFromEntered();
                    }
                    break;
                case (6):
                    {
                        Console.Clear();
                        SingleCellAmoeba();
                    }
                    break;
                case (7):
                    {
                        Console.Clear();
                        BankSaving();
                    }
                    break;
                    case (8):
                        {
                            Console.Clear();
                            DivBy3ButNotBy5();
                        }
                   break;
                    case (9):
                        {
                            Console.Clear();
                            ReverseNumber();
                        }
                        break;

            }
                Console.WriteLine("");
                Console.WriteLine("Do you want to continue? 1-yes, 2-no");
                answear = Int32.Parse(Console.ReadLine());
                Console.Clear();
                
            } while (answear == 1);

        }


        static void CountOfPosNegZer()
        {
            decimal entry;
            decimal positive = 0;
            decimal negative = 0;
            decimal zero = 0;
            Console.WriteLine("enter quantity of input numbers");
            decimal input = Decimal.Parse(Console.ReadLine());
            for (; input > 0; input--)
            {
                Console.WriteLine("enter a number");
                entry = Decimal.Parse(Console.ReadLine());
                if (entry == 0) zero++;
                if (entry < 0) negative++;
                if (entry > 0) positive++;
            }
            Console.WriteLine("{0} positive,  {1} negative, {2} zero numbers", positive, negative, zero);
        }
        static void DividedByFive()
        {
            int n;
            for (n = -99; n <= -10; n++)
            {
                if (n % 5 == 0)
                {
                    Console.WriteLine(n);
                }
                for (n = -99; n <= -10; n++)
                {
                    if (n % 5 == 0) Console.WriteLine(n);
                }

                for (n = 10; n <= 99; n++)
                {
                    if (n % 5 == 0) Console.WriteLine(n);
                }
            }
        }
        static void MultiDigitNumber()
        {
            int counter = 1;
            int max = 0;
            int min = 9;
            Console.WriteLine("enter a number");
            int number = Int32.Parse(Console.ReadLine());
            while (number / 10 > 0)
            {
                counter++;
                int lastDigit = number % 10;
                number = number / 10;
                if (lastDigit > max)
                {
                    max = lastDigit;
                }
                if (lastDigit < min)
                {
                    min = lastDigit;
                }
            }
            if (number > max)
            {
                max = number;
            }
            if (number < min)
            {
                min = number;
            }
            Console.WriteLine("number consists of {0} digit(s).", counter);
            Console.WriteLine("maximum digit is {0}.", max);
            Console.WriteLine("minimum digit is {0}.", min);
        }
        static void SecondPower()
        {
            int i = 10;
            int result;
            while (i <= 20)
            {
                result = i * i;
                Console.WriteLine("{0}^2 = {1}", i, result);
                i++;
            }
        }
        static void MaxFromEntered()
        {
            decimal max = Decimal.MinValue;
            int counter = 1;
            Console.WriteLine("Enter 5 numbers");
            do
            {
                decimal input = Decimal.Parse(Console.ReadLine());
                if (input > max) max = input;
                counter++;
            }
            while (counter <= 5);
            Console.WriteLine("maximum is {0}.", max);
        }
        static void SingleCellAmoeba()
        {
            decimal amoeba = 1;
            decimal division;
            Console.WriteLine("enter number of hours");
            decimal hours = Decimal.Parse(Console.ReadLine());
            if (hours >= 3)
            {
                division = (Decimal.Floor(hours / 3));
                do
                {
                    amoeba = amoeba * 2;
                    division--;
                }
                while (division > 0);
            }
            Console.WriteLine("after {0} hours, there will be {1} amoebas.", hours, amoeba);

        }
        static void BankSaving()
        {
            Console.WriteLine("Enter amount of money");
            double initialSum = Double.Parse(Console.ReadLine());
            Console.WriteLine("Enter period in years");
            int years = Int32.Parse(Console.ReadLine());
            double outputSum = initialSum;
            int counter = years;
            for (; counter > 0; counter--)
            {
                outputSum = (outputSum * 1.03);               
            }
            Console.WriteLine("After {0} years you'll get {1}", years, outputSum);
        }
        static void DivBy3ButNotBy5()
        {
            int input=20;
            do
            {
                input++;
                if ((input % 3 == 0) && (input % 5 != 0)) Console.WriteLine(input);
            }
            while (input < 50);
        }
        static void ReverseNumber()
        //{
        //    int digit;
        //    Console.WriteLine("enter an integer number");
        //    int number = Int32.Parse(Console.ReadLine());
        //    do
        //    {
        //        digit = number % 10;  
        //        Console.Write(digit);
        //        number = number / 10;
        //    }   
        //    while (number!= 0);
        //}
        {
            double digit;
            int number2;
            int counter = 0;
            double revertedNumber=0;
            Console.WriteLine("enter an integer positive number");
            int number = Int32.Parse(Console.ReadLine());
            number2 = number;

            while (number2 / 10 > 0)
            {
                counter++;
                number2 = number2 / 10;
            }

            do
            {
                digit = (number % 10) * (Math.Pow(10,counter));
                number = number / 10;
                revertedNumber = revertedNumber+digit;
                counter--;
            }
            while (counter >= 0);
           Console.WriteLine(revertedNumber);
        }
    }
}
